#include <proxy/proxy.h>

#include <format>
#include <iostream>
#include <memory>
#include <vector>

// 定义绘制接口
PRO_DEF_MEM_DISPATCH(DrawDispatch, draw);

struct Drawable : pro::facade_builder ::                        //
                  add_convention<DrawDispatch, void() const>::  //
                  support_copy<pro::constraint_level::nontrivial>::build
{
};

// 实现类
class Circle
{
public:
    Circle(double radius) : radius_(radius) {}
    void draw() const { std::cout << std::format("Drawing Circle with radius: {}\n", radius_); }

private:
    double radius_;
};

class Rectangle
{
public:
    Rectangle(double w, double h) : width_(w), height_(h) {}
    void draw() const { std::cout << std::format("Drawing Rectangle {}x{}\n", width_, height_); }

private:
    double width_, height_;
};

class Triangle
{
public:
    Triangle(double base, double height) : base_(base), height_(height) {}
    void draw() const { std::cout << std::format("Drawing Triangle base={}, height={}\n", base_, height_); }

private:
    double base_, height_;
};

void polymorphism_example()
{
    // 创建代理数组
    std::vector<pro::proxy<Drawable>> shapes;
    shapes.push_back(pro::make_proxy<Drawable, Circle>(5.0));
    shapes.push_back(pro::make_proxy<Drawable, Rectangle>(10.0, 20.0));
    shapes.push_back(pro::make_proxy<Drawable, Triangle>(15.0, 25.0));

    // 多态调用
    std::cout << "Drawing all shapes:\n";
    for (const auto& shape : shapes)
    {
        shape->draw();
    }

    // 显示类型信息
    std::cout << std::format("Total shapes: {}\n", shapes.size());
}